#import <Foundation/Foundation.h>

// 获取应用程序包资源路径的 C 函数
const char* get_bundle_resource_path(void) {
    @autoreleasepool {
        NSBundle* mainBundle = [NSBundle mainBundle];
        NSString* resourcePath = [mainBundle resourcePath];
        if (resourcePath) {
            return strdup([resourcePath UTF8String]);
        }
    }
    return NULL;
}

// 获取应用程序包中指定资源的完整路径
const char* get_bundle_resource_file_path(const char* filename) {
    @autoreleasepool {
        NSBundle* mainBundle = [NSBundle mainBundle];
        NSString* nsFilename = [NSString stringWithUTF8String:filename];
        
        // 获取文件名和扩展名
        NSString* basename = [nsFilename stringByDeletingPathExtension];
        NSString* extension = [nsFilename pathExtension];
        
        // 查找资源文件
        NSString* path = [mainBundle pathForResource:basename ofType:extension];
        if (path) {
            return strdup([path UTF8String]);
        }
    }
    return NULL;
} 